package org.jeecg.modules.demo.projectroom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.demo.projectroom.entity.ZnzfProjectProvince;
import org.jeecg.modules.demo.projectroom.mapper.ZnzfProjectProvinceMapper;
import org.jeecg.modules.demo.projectroom.service.IZnzfProjectProvinceService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 项目表省份-站段-地市联动控件
 * @Author: jeecg-boot
 * @Date:   2022-04-10
 * @Version: V1.0
 */
@Service
public class ZnzfProjectProvinceServiceImpl extends ServiceImpl<ZnzfProjectProvinceMapper, ZnzfProjectProvince> implements IZnzfProjectProvinceService {

    @Resource
    private ZnzfProjectProvinceMapper mapper;
    /**
     * 根据pid获取所有子节点
     *
     * @param pid
     * @return
     */
    @Override
    public List<ZnzfProjectProvince> getChildrenByPid(String pid) {
        LambdaQueryWrapper<ZnzfProjectProvince> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ZnzfProjectProvince::getPid,pid);
        return mapper.selectList(wrapper);
    }

    /**
     * 根据名称查对象
     *
     * @param name
     * @return
     */
    @Override
    public ZnzfProjectProvince getItemByName(String name) {
        LambdaQueryWrapper<ZnzfProjectProvince> wrapper = new LambdaQueryWrapper();
        wrapper.eq(ZnzfProjectProvince::getName,name);
        return mapper.selectOne(wrapper);
    }
}
